"""
Copyright (c) 2023 - present SKbioinfo
"""

from apps.NGS_API.connect import MysqlConnection
from apps.NGS_API.common.db_table_config import *

def get_project_info():
    ### set up MYSQL connection ###
    db_conn=MysqlConnection()
    ### SQL: total number of projects ###
    project_total_sql = '''
    SELECT 
        COUNT(DISTINCT {col}) 
    FROM {table_name}
    '''.format( 
        col = "project_id",
        table_name = project_db["name"]
    )
    project_total_number = (db_conn.Query(project_total_sql))[0]
    ### SQL: project_base_info_sql ###
    project_base_info_sql = '''
    SELECT	
        project_id,
		client_id,
		product_id,
		protocol_id,
        sample_receive_id,
        project_type,
        project_level,
        create_user,
        incharge_user,
        create_time,
        modify_time,
        id,
        status,
        project_tag,
        primary_id
    FROM {table_name};
    '''.format(
        table_name = project_db["name"]
    )
    project_base_info = db_conn.Query(project_base_info_sql)
    db_conn.close_conn()
    return project_total_number,project_base_info